// /common/http.api.js

// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let homeSearchUrl = '/home/search';
let homeTools = '/home/tools';
let homeHswiper = '/home/hswiper';
let homeTips_t = '/home/tips_t';
let homeSwiper = '/home/swiper';
let homeInfo = '/home/info';
let homeTips_b = '/home/tips_b'

//ideabooks
let ideaTypeMsg = '/ideabooks/typemsg';
let ideaMsgList = '/ideabooks/msglist';

					 

//notifications
let notiftItem = '/notifications/item';

//profile
let profileUser = '/profile/user';
let profileSystem = 'profile/system';

// let indexUrl = '/ebapi/public_api/index';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 此处没有使用传入的params参数
	// let getSearch = (homeSearchUrl,params = {}) => vm.$u.get(homeSearchUrl, params);
	//Home
	let getSearch = (param)=>vm.$u.get(homeSearchUrl+param);
	let getTools = (param)=>vm.$u.get(homeTools);
	let getHSwiper = (param1,param2)=>vm.$u.get(homeHswiper+param1+param2);
	let getTips_t = ()=>vm.$u.get(homeTips_t);
	let getSwiper = (param1,param2)=>vm.$u.get(homeSwiper+param1+param2);
	let getInfo = ()=>vm.$u.get(homeInfo);
	let getTips_b = ()=>vm.$u.get(homeTips_b);
	//ideabooks
	let getTypeMsg = ()=>vm.$u.get(ideaTypeMsg);
	let getMsgList = (param1,param2)=>vm.$u.get(ideaMsgList+param1+param2);
	//notifications
	let getItemList = (param1,param2)=>vm.$u.get(notiftItem+param1+param2);
	//profile
	let getUser = (param)=>vm.$u.get(profileUser+param);
	let getSystem = ()=>vm.$u.get(profileSystem);
	// 此处使用了传入的params参数，一切自定义即可
	// let getInfo = (params = {}) => vm.$u.post(indexUrl, params);
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {getSearch,
				getTools,
				getHSwiper,
				getTips_t,
				getSwiper,
				getInfo,
				getTips_b,
				getTypeMsg,
				getMsgList,
				getItemList,
				getUser,
				getSystem};

	// vm.$u.api = {getSearch, getInfo};
}

export default {
	install
}